package com.jp.app.server;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

import org.hsqldb.server.Server;

public class HSqlDatabaseSetup extends HttpServlet {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	Server server;
	String path = "file:hsqldb/db";
	
	public void init() throws ServletException {
		connect();
	}
		
	public void connect(){
		server = new Server();
		server.setAddress("localhost");
		server.setDatabaseName(0, "mydb1");
		
		server.setDatabasePath(0, path);
		server.setPort(1234);
		server.setTrace(true);
		server.setLogWriter(new PrintWriter(System.out));
		server.start();
		try {
			Class.forName("org.hsqldb.jdbc.JDBCDriver");
		} catch (ClassNotFoundException e) {
			e.printStackTrace(System.out);
		}
	}

}
